package com.util.vmwareops;
import com.vmware.vim25.mo.ServiceInstance;

import javax.xml.ws.soap.SOAPFaultException;

import java.net.URL;
@Deprecated
public class ClientSession {
    private static String hostName = "182.242.100.10";
    private static int port = 443;
    private static String userName = "administrator@vsphere.local";
    private static String password = "VMware123!";
    private static ServiceInstance serviceInstance = null;

    private static void initServiceInstance() throws Exception {
        if(serviceInstance == null) {
            URL vCenterURL= new URL("https://"+hostName+":"+port+"/sdk");
            //Login to vCenter using Yavijava provided ServiceInstance object
            try {
                serviceInstance= new ServiceInstance(vCenterURL,userName,password,true, 50000, 50000);
            } catch(SOAPFaultException sfe) {
                sfe.printStackTrace();
            } catch(Exception e) {
                e.printStackTrace();
            }

        }
    }
    public static synchronized ServiceInstance getInstance() throws Exception {
        initServiceInstance();
        return serviceInstance;
    }
}
